class Solution(object):
    def maximumBobPoints(self, numArrows, aliceArrows):
        def cal(val):
            ans = 0
            score = 0
            for i in range(12):
                if (val >> i) & 1:
                    ans += aliceArrows[i] + 1
                    score += i
            if ans <= numArrows:
                return score
            else:
                return 0
        max_score= 0
        for val in range(1 << 12):
            score = cal(val)
            if score > max_score:
                max_score = score
                max_val = val
        out = [0] * 12
        for i in range(12):
            if (max_val >> i) & 1:
                out[i] = aliceArrows[i] + 1
        if sum(out) < numArrows:
            out[0] += numArrows - sum(out)
        return out